package com.jt.feign;

import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author 金帮嘉诚 @date 2021-08-18 星期三 15:18
 */
//此对象可以作为Feign方式的远程调用异常处理对象
@Component
public class ProviderFallbackFactory
        implements FallbackFactory<RemoteProviderService> {
    @Override
    public RemoteProviderService create(Throwable throwable) {
//        return new RemoteProviderService() {//匿名内部类
//            @Override
//            public String echoMsg(String msg) {
//                //...通知运维人员(发短信 发邮件 电话)...
//                return "服务维护中";
//            }
//        };
        return (msg) ->{//Lambdas表达式
            return "服务维护中";
        };
    }
}
